package com.yj.lcj.weather.controller;

import com.yj.lcj.weather.response.ResultData;
import com.yj.lcj.weather.service.WeatherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/weather")
@Api(tags = "天气接口")
public class WeatherController {

    @Autowired
    private WeatherService weatherService;

    /**
     * 返回天气状况
     * @param needday 1 代表实时天气 7:7天 15:15天  24:24小时
     * @param prov 省份
     * @param city 城市
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(name ="needday",value="needday 1 代表实时天气 7:7天 15:15天  24:24小时" ,required = true,dataType = "String"),
            @ApiImplicitParam(name ="prov",value="省份" ,required = true,dataType = "String"),
            @ApiImplicitParam(name ="city",value="城市" ,required = true,dataType = "String"),
            @ApiImplicitParam(name ="area",value="区县(参数可选)" ,required = false,dataType = "String"),
    })
    @ApiOperation(value = "获取天气信息")
    @GetMapping(value = "/getWeather")
    public String resultData(@RequestParam("needday") String needday, @RequestParam("prov") String prov, @RequestParam("city") String city, @RequestParam(value = "area",required = false) String area) throws IOException {
        return weatherService.getRealTimeWeather(needday,prov,city,area);
    }
}
